#include <cstdio>
#include <cstring>
#include <iostream>
using namespace std;
const int maxn = 18;
int g[maxn][maxn], f[maxn][(1 << maxn)], n, ans = 0x3f3f3f3f;
int main() {
#ifndef LOCAL
    freopen("salesman.in", "r", stdin);
    freopen("salesman.out", "w", stdout);
#endif
    ios::sync_with_stdio(false);
    cin >> n;
    for (int i = 0; i < n; i++)
        for (int j = 0; j < n; j++)
            cin >> g[i][j];
    memset(f, 1, sizeof(f));
    f[0][1] = 0;
    for (int s = 1; s < (1 << n); s += 2)
        for (int i = 0; i < n; i++)
            if (!((1 << i) & s))
                for (int j = 0; j < n; j++)
                    if ((1 << j) & s)
                        f[i][(1 << i) | s] = min(f[i][(1 << i) | s], f[j][s] + g[j][i]);
    for (int i = 1; i < n; i++)
        ans = min (ans, f[i][(1 << n) - 1] + g[i][0]);
    cout << ans << endl;
}